//
//  ZJMainTabBarController.m
//  zjzb
//
//  Created by Mac on 2017/3/24.
//  Copyright © 2017年 Mac. All rights reserved.
//

#import "ZJMainTabBarController.h"
#import "ZJMineViewController.h"
#import "ZJPullViewController.h"
#import "ZJPushViewController.h"
#import "SXTBaseNavViewController.h"
#import "ZJTabBar.h"
@interface ZJMainTabBarController ()<ZJTabBarDelegate>

@property (nonatomic, strong) ZJTabBar * sxtTabbar;

@end

@implementation ZJMainTabBarController

- (ZJTabBar *)sxtTabbar {
    
    if (!_sxtTabbar) {
        _sxtTabbar = [[ZJTabBar alloc] initWithFrame:CGRectMake(0, 0, DEF_SCREEN_WIDTH, 49)];
        _sxtTabbar.delegate = self;
    }
    return _sxtTabbar;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self addVcs];
    [self.tabBar addSubview:self.sxtTabbar];
    self.tabBar.tintColor = DEF_RGBA_COLOR(0, 216, 201, 1);
    //删除tabbar的阴影线
    [[UITabBar appearance] setShadowImage:[UIImage new]];
    [[UITabBar appearance] setBackgroundImage:[UIImage new]];
}

-(void)zjtabbar:(ZJTabBar *)tabbar WithIndex:(NSInteger)index{
    
     self.selectedIndex = index - 1000;
    
}
-(void)addVcs {
    
    NSMutableArray * array = [NSMutableArray arrayWithArray:@[@"ZJPullViewController",@"ZJPushViewController",@"ZJMineViewController"]];
    
    NSArray * arrayName = @[@"看于总直播",@"自己播",@"我的"];
    
    for (NSInteger i = 0; i < array.count; i ++) {
        
        NSString * vcName = array[i];
        
        UIViewController * vc = [[NSClassFromString(vcName) alloc] init];
        
        vc.title = arrayName[i];
        
        SXTBaseNavViewController * nav = [[SXTBaseNavViewController alloc] initWithRootViewController:vc];
        
        [array replaceObjectAtIndex:i withObject:nav];
        
    }
    
    self.viewControllers = array;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
